<%@include file="/WEB-INF/views/includes/taglibs.jsp"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@include file="/WEB-INF/views/includes/adminHeader.jsp"%>



<!--[if gte IE 6]>
<script>
$(document).ready( function() {
$(".dataRow").mouseover(function(){$(this).addClass("dataRowOver");});
$(".dataRow").mouseout(function(){$(this).removeClass("dataRowOver");});
});
</script>
<![endif]-->
<script type="text/javascript">
function editConnection(id) {
	window.location.href = "<c:url value='/web/editFunction?id='/>" + id;
}
function addNewSystem() {
	$('#newSystemDialog').dialog('open');
}

function loadEditSystemBlock(systemId) {
	var baseUrl = "<c:url value='/web/editBizSystem'/>";
	var ajaxurl = baseUrl + '?bizsysId=' + systemId;
	$.ajax({
		  url: ajaxurl,
		  success: function(data) {
		    $('#editbizGroupDialog').html('');
		    $('#editbizGroupDialog').html(data);
		    $('#editbizGroupDialog').dialog('open');
		  }
	});
}

$(document).ready(
		function() {
			$('#newSystemDialog').dialog({
				autoOpen: false,
				width: 600,
				draggable : true,
				resizable : false,
				dialogClass : 'commonDialog',
				buttons: {
					"Ok": function() {
						$('#newbizsysform').submit();
					},
					"Cancel": function() {
						$(this).dialog("close");
					}
				}
			});
			
			$('#editbizGroupDialog').dialog({
				autoOpen: false,
				width: 600,
				draggable : true,
				resizable : false,
				dialogClass : 'commonDialog',
				buttons: {
					"Save": function() {
						$('#editBizSystemform').submit();
					},
					"Cancel": function() {
						$(this).dialog("close");
					}
				}
			});
		});
</script>
<div title="Add new business system" id="newSystemDialog">
	<h3>Add new business system</h3>
	<form:form method="post" action="addBizSystem" id="newbizsysform">
		<div style="font-size:12px;margin-bottom:10px"><span class="label" style="width:200px">Name:</span><span><form:input style="width:300px" path="name"/></span></div>
		<div style="font-size:12px;margin-bottom:10px"><span class="label" style="width:200px">Connector Statics Class Name:</span><span><form:input style="width:300px" path="connectorStaticsClassName"/></span></div>
	</form:form>
	<br/>
</div>
<div id="editbizGroupDialog" title="Edit business system">

</div>
<div class="homePage ui-tabs-panel ui-widget-content ui-corner-bottom">
	<div id="leftMenu">
		<%@include file="/WEB-INF/views/includes/bizsysAdminLeftNav.jsp"%>
	</div>
	<div id="rightContent">
		<%@include file="/WEB-INF/views/includes/messages.jsp"%>
		<h2>Business Systems</h2>
		<div class="searchBlock">
				<button type="button"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						onclick="addNewSystem()" style="margin-top:5px">
						<span class="ui-button-text">Add new Business System</span>
				</button>
				<br/><br/>
		</div>
		<div>
			<table class="generaltable" style="width:100%" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<th>Name</th>
						<th>Connector Class Name</th>
						<th>Operation</th>
					</tr>
				</thead>
				<tbody>
				<c:if test="${not empty bizSystemList}">
					<c:forEach items="${bizSystemList}" var="oneSystem">
					<tr class="dataRow">
						<td>${oneSystem.name}</td>
						<td>${oneSystem.connectorStaticsClassName}</td>
						<td>
							<a href="#" onclick="loadEditSystemBlock('${oneSystem.id}')">Edit</a>&nbsp;&nbsp;
							<a href="<c:url value='/web/connectorConfigures?bizsysid=${oneSystem.id}'/>">Connector Configure</a>			
						</td>
					</tr>
					</c:forEach>
				</c:if>
				</tbody>
			</table>
		</div>
		<div style="height:1px;width:740px;"></div>
	</div>
</div>

<%@include file="/WEB-INF/views/includes/adminfooter.jsp"%>